import 'package:flutter/material.dart';
import 'package:flutter_common/ui/widget/click.dart';

///播放标题  关闭图标+标题+末尾的可点击文本
class PlayTitle extends StatelessWidget {
  final String? title;
  final Function()? onCloseTap;

  //右侧 文本、是否显示、点击事件
  final String? rightText;
  final bool showRight;
  final Function()? onRightTap;

  const PlayTitle({
    super.key,
    this.title,
    this.onCloseTap,
    this.showRight = false,
    this.rightText = "修改名称",
    this.onRightTap,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        FxClick(
          onTap: onCloseTap ??
              () {
                Navigator.pop(context);
              },
          child: const Padding(
            padding: EdgeInsets.symmetric(vertical: 19, horizontal: 16),
            child: Icon(Icons.close,color: Colors.white, size: 16),
          ),
        ),
        Expanded(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 13),
            child: Text(
              title ?? '',
              style: const TextStyle(color: Colors.white, fontSize: 16),
              overflow: TextOverflow.ellipsis,
            ),
          ),
        ),
        if (showRight)
          FxClick(
            onTap: onRightTap,
            borderRadius: BorderRadius.circular(4),
            child: Padding(
              padding: const EdgeInsets.symmetric(vertical: 13, horizontal: 15),
              child: Text(
                rightText ?? '',
                style: const TextStyle(color: Colors.white, fontSize: 14),
              ),
            ),
          ),
      ],
    );
  }
}

///背景白色 中间红色的暂停、播放按钮
class PlayButton extends StatelessWidget {
  final bool playing;
  final Widget? icon;
  final Widget? selectIcon;
  final Function()? onTap;

  const PlayButton({
    super.key,
    this.playing = false,
    this.icon,
    this.selectIcon,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    Widget child;
    if (playing) {
      child = selectIcon ?? Text("playing");
    } else {
      child = icon ?? Text("start");
    }
    return FxClick(
      onTap: onTap,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(23),
      ),
      borderRadius: BorderRadius.circular(23),
      child: SizedBox(
        width: 45,
        height: 45,
        child: child,
      ),
    );
  }
}
